python code for weighted average ensemble